﻿using UnityEngine;
using System.Collections;
using Helper;

[ExecuteInEditMode]
public class DrawCurves : MonoBehaviour {
	[SerializeField] Transform[] path;
	Vector3[] pathPoints;
	[SerializeField] float periodNum = 0.5f;
	[SerializeField] float startPeriod = 0f;
	[SerializeField] float amplitude = 1f;
	// Use this for initialization
	void Awake () {
		pathPoints = new Vector3[path.Length];
		for (int i = 0; i < path.Length; i++) {
			pathPoints [i] = path [i].position;
		}
	}
	
	void OnDrawGizmos(){
		//MyTween.DrawSin (startTran.position, endTran.position, amplitude, 0f, periodNum, -Time.time);
		MyTween.DrawSin (startTran.position, endTran.position, amplitude: amplitude, periodNum: periodNum, startPeriod: -Time.time);
		//MyTween.DrawPath (pathPoints, Color.red);
		//Gizmos.DrawSphere (MyTween.GetPos (pathPoints, Time.time - (int)Time.time), 1f);
		//DrawParabolic ();
		DrawNode ();
		//Gizmos.DrawSphere (MyTween.GetPosInParabolic (startTran.position, endTran.position, horizontalVelocity, gravity, time), 1f);
	}
	[SerializeField] Transform startTran;
	[SerializeField] Transform endTran;
	[SerializeField] float horizontalVelocity = 10f;
	[SerializeField] float gravity = 9.8f;
	[SerializeField] float time;
	void DrawParabolic(){
		MyTween.DrawParabolic (startTran.position, endTran.position, horizontalVelocity, gravity);
	}
	void DrawNode(){
		foreach (Transform tr in path) {
			Gizmos.DrawSphere (tr.position, 1f);
		}
		Gizmos.DrawSphere (startTran.position, 0.1f);
		Gizmos.DrawSphere (endTran.position, 0.1f);
	}
}
